#ifndef _CDATAPOOLSERVER_H
#define _CDATAPOOLSERVER_H

#include <boost/thread/thread.hpp>
#include <boost/thread/xtime.hpp>
#include <boost/function.hpp>
#include <vector>
#include <map>
#include <set>

#define DTPS_THREAD_PORT			666

class CDatapoolServer
{
  public:

  	typedef enum
  	{
  		Get = 0,
  		Set = 1
	}Msg_Code_t;

    typedef struct
    {
      Msg_Code_t MsgCode;
	  void * MsgBuf;
	}Msg_t;

	typedef struct
	{
	  int identifiant;
	  void * value;
	}MsgSet_t;

	typedef struct
	{
	  int identifiant;
	}MsgGet_t;

	typedef enum
	{
		Bool = 0,
		Char,
		Int,
		Double,
		Composite
	}type_t;

	typedef struct
	{
		type_t type;
		void * value;
	}Cdata_t;

	typedef struct
	{
		int size;
		void * value;
	}CdataComposite_t;

	CDatapoolServer();
    ~CDatapoolServer();

    bool m_shallStop;

    boost::thread * m_Thread;

    void Run();
    void Stop();

    void RunThread();
    void RunSocketThread(int soketfd);

    Cdata_t* GetData(int & Identifiant);

    int RegisterData(Cdata_t * Data);
  private:

    std::vector<Cdata_t *> m_DataPool;
    std::vector<boost::thread *> m_ThreadPool;

};

extern CDatapoolServer DataServer;

#endif
